﻿//开始调用Ajax
/*
url:要访问的链接   参数类型:String
paramMap:参数列表  参数类型:Map
callBack:回调接口  参数类型:js对象
注:callBack对象类一定要有onSuccess(ResultBean rb)方法和onFail(ResultBean rb)方法
*/
function AjaxStart(url, paramet, callBack) {
    adminid = adminid == null ? "" : adminid;
    token = token == null ? "" : token;
    //显示等待框
    wait.show("加载");
    $.ajax({
        url: url,
        type: 'post',
        dataType: "json",
        data: encodeURI(paramet + "&adminid=" + adminid + "&token=" + token),
        success: function (json) {
            if (json == null) {
                toast.show("服务器返回数据失败");
                return;
            }

            wait.dismiss();
  
            if (json.code.toString() == "5" || json.code.toString() == "7") {
                window.location.href = "login.html";
            }
            callBack(json);
        },
        error: function (rs) {
            toast.show("服务器故障!");
        }
    });
}


var ajax = new AjaxData();



function AjaxData() {
 
    this.getAjax = function (Url, paramet, callback) {
 
        AjaxStart(Url, paramet, callback);
    }

    //注册
    this.Regist = function (paramet, callback) {

        AjaxStart(ajaxUrl.Regist, paramet, callback);
    }

    //登录
    this.Login = function (paramet, callback) {

        AjaxStart(ajaxUrl.Login, paramet, callback);
    }

 
    //获取详细信息
    this.GetDetail = function (paramet, callback) {
 
        AjaxStart(ajaxUrl.GetDetail, paramet, callback);
    }

    //修改密码
    this.Editpwd = function (paramet, callback) {
     
        AjaxStart(ajaxUrl.Editpwd, paramet, callback);
    }
    //忘记密码
    this.ForgetPwd = function (paramet, callback) {

        AjaxStart(ajaxUrl.ForgetPwd, paramet, callback);
    }


    //修改昵称
    this.Updatenickname = function (paramet, callback) {

        AjaxStart(ajaxUrl.Updatenickname, paramet, callback);
    }
    //修改个人信息
    this.UpdateInfo = function (paramet, callback) {

        AjaxStart(ajaxUrl.UpdateInfo, paramet, callback);
    }

    //文章列表
    this.getarticleList = function (paramet, callback) {

        AjaxStart(ajaxUrl.articleList, paramet, callback);
    }
    //文章添加
    this.Addarticle = function (paramet, callback) {

        AjaxStart(ajaxUrl.Addarticle, paramet, callback);
    }

    //文章详情
    this.ArticleDetail = function (paramet, callback) {

        AjaxStart(ajaxUrl.ArticleDetail, paramet, callback);
    }

    //文章移除
    this.Detelearticle = function (paramet, callback) {
     
        AjaxStart(ajaxUrl.Detelearticle, paramet, callback);
    }

    //默认频道
    this.defualtlist = function (paramet, callback) {
        AjaxStart(ajaxUrl.Getdefualtlist, paramet, callback);
    }
    //频道列表
    this.Getchelist = function (paramet, callback) {
        AjaxStart(ajaxUrl.Getlist, paramet, callback);
    }

    //添加收藏
    this.Addcollection = function (paramet, callback) {

        AjaxStart(ajaxUrl.Addcollection, paramet, callback);
    }
    //移除收藏
    this.Removecollection = function (paramet, callback) {

        AjaxStart(ajaxUrl.Removecollection, paramet, callback);
    }
    //收藏列表
    this.Getconlltionlist = function (paramet, callback) {

        AjaxStart(ajaxUrl.Getconlltionlist, paramet, callback);
    }

    //添加广告
    this.Addadvert = function (paramet, callback) {

        AjaxStart(ajaxUrl.Addadvert, paramet, callback);
    }
    //移除广告
    this.Removeadvert = function (paramet, callback) {

        AjaxStart(ajaxUrl.Removeadvert, paramet, callback);
    }
    //广告列表
    this.Getadvertlist = function (paramet, callback) {

        AjaxStart(ajaxUrl.Getadvertlist, paramet, callback);
    }
    //修改广告
    this.Editadvert = function (paramet, callback) {

        AjaxStart(ajaxUrl.Editadvert, paramet, callback);
    }
    //广告详细
    this.Detailadvert = function (paramet, callback) {

        AjaxStart(ajaxUrl.Detailadvert, paramet, callback);
    }
 
    //添加分享
    this.AddShare = function (paramet, callback) {

        AjaxStart(ajaxUrl.AddShare, paramet, callback);
    }
    //移除分享
    this.RemoveShare = function (paramet, callback) {

        AjaxStart(ajaxUrl.RemoveShare, paramet, callback);
    }
    //分享列表
    this.GetSharelist = function (paramet, callback) {
 
        AjaxStart(ajaxUrl.GetSharelist, paramet, callback);
    }

    //统计汇总
    this.GetCount = function (paramet, callback) {
        AjaxStart(ajaxUrl.GetCount, paramet, callback);
    }


    //分享查看数
    this.Sharequery = function (paramet, callback) {
        AjaxStart(ajaxUrl.Sharequery, paramet, callback);
    }
    //分享点击数
    this.ShareClick = function (paramet, callback) {
        AjaxStart(ajaxUrl.ShareClick, paramet, callback);
    }


    //广告查看数
    this.Advertquery = function (paramet, callback) {
        AjaxStart(ajaxUrl.Advertquery, paramet, callback);
    }

    //广告点击数
    this.AdvertClick = function (paramet, callback) {
        AjaxStart(ajaxUrl.AdvertClick, paramet, callback);
    }

}
var ajaxUrl = new Url();
function Url() {
 
    //注册
    this.Regist = "Ajax/User.ashx?Regist";
    //登录
    this.Login = "Ajax/User.ashx?Login";
    //修改昵称
    this.Updatenickname = "Ajax/User.ashx?UpdateNickName";
    //修改个人信息
    this.UpdateInfo = "Ajax/User.ashx?UpdateInfo";

    //修改密码
    this.Editpwd = "Ajax/User.ashx?ModifyPwd";
    //忘记密码
    this.ForgetPwd = "Ajax/User.ashx?ForgetPwd";

    //获取详细信息
    this.GetDetail = "Ajax/User.ashx?GetDetail";

    //文章添加
    this.Addarticle = "Ajax/Article.ashx?Add";

    //文章详情
    this.ArticleDetail = "Ajax/Article.ashx?GetDetail";

    //文章移除
    this.Detelearticle = "Ajax/Article.ashx?Remove";
    //文章列表
    this.articleList = "Ajax/Article.ashx?GetList";

    //获取默认频道
    this.Getdefualtlist = "Ajax/Channel.ashx?GetDefaultList";
    //获取文章频道列表
    this.Getlist = "Ajax/Channel.ashx?GetList";

    //收藏
    this.Addcollection = "Ajax/Collect.ashx?Add";
    this.Removecollection = "Ajax/Collect.ashx?Remove";
    this.Getconlltionlist = "Ajax/Collect.ashx?GetList";

    //广告
    this.Addadvert = "Ajax/advert.ashx?Add";
    this.Removeadvert = "Ajax/advert.ashx?Remove";
    this.Getadvertlist = "Ajax/advert.ashx?GetList";
    this.Editadvert = "Ajax/advert.ashx?Update";
    this.Detailadvert = "Ajax/advert.ashx?GetDetail";

    //分享
    this.AddShare = "Ajax/Shared.ashx?Add";
    this.RemoveShare = "Ajax/Shared.ashx?Remove";
    this.GetSharelist = "Ajax/Shared.ashx?GetList";

    //统计数量
    this.GetCount = "Ajax/Statistics.ashx?GetCount";

    //分享查看数
    this.Sharequery = "Ajax/Statistics.ashx?GetViewSharedList";
    //分享点击数
    this.ShareClick = "Ajax/Statistics.ashx?GetClickSharedList";


    //广告查看数
    this.Advertquery = "Ajax/Statistics.ashx?GetViewAdvertList";
    //广告点击数
    this.AdvertClick = "Ajax/Statistics.ashx?GetClickAdvertList"

    //上传图片
    this.Upimg = "Ajax/Upload.ashx?Img";
}
 